package com.coldworks.base.task;

import android.content.Context;

import com.coldworks.base.BaseThread;
import com.coldworks.base.manager.BaseNetworkManager;
import com.coldworks.base.manager.BaseSplashManager;
import com.coldworks.base.util.BaseCONST;

/**
 * 同步欢迎页
 * 
 * @since 2012-03-23
 */
public class BaseSplashSyncTask extends BaseThread {
	private Context ctx;
	private String url;

	public BaseSplashSyncTask(Context context, String url) {
		this.ctx = context;
		this.url = url;
	}

	/**
	 * 下载服务器中的闪屏文件列表,通過mergeSplash方法与本地文件进行增删改同步
	 */
	@Override
	public void run() {
		try {
			Thread.sleep(BaseCONST.TASK.SPLASH_SYNC_SECOND * 1000);
		} catch (InterruptedException e) {
			log.error("", e);
			return;
		}
		if (!BaseNetworkManager.getInstance().isWifiConnected(ctx)) {
			log.info("not wifi, do nothing");
		}
		log.info("start splash syncing");
		BaseSplashManager.getInstance().splashSync(ctx, this.url);
		log.info("done");
	}

}
